import UserAPI from "@/api/system/user.api";
import { store } from "@/store";
import logo from "@/assets/logo.png";

export const useLogoStore = defineStore("logo", () => {
  // 仓库
  const logoInfo = useStorage("logoInfo", { logo_img: "", logo_title: "" });

  const getLogoInfo = async () => {
    let result = await UserAPI.getLogoInfo();
    logoInfo.value.logo_img = result.logo_img.indexOf("uploads") === -1 ? logo : result.logo_img;
    logoInfo.value.logo_title = result.logo_title || "黑幕后台管理系统";
  };
  return {
    logoInfo,
    getLogoInfo,
  };
});

export function useLogoStoreHook() {
  return useLogoStore(store);
}
